var assert = require('assert');
var DomainIp = require('../util/lib/domain-ip');
var tools = require('../src/tools')
var ips = [
  'dsb-mi-test.dingtax.cn',
  'dsb-mi.ifugle.com',
  '*.baidu.com',
  '172.16.21.23',
  '172.16.21.*'
];

var domainIps = [
  new DomainIp(ips[0]),
  new DomainIp(ips[1]),
  new DomainIp(ips[2]),
  new DomainIp(ips[3]),
  new DomainIp(ips[4])
]

describe('安全域名或者IP', function() {
  it('域名一致', function() {
    var ip = 'dsb-mi-test.dingtax.cn'
    assert.equal(domainIps[0].isIn(ip), true);
    assert.equal(domainIps[1].isIn(ip), false);
    assert.equal(domainIps[2].isIn(ip), false);
    assert.equal(domainIps[3].isIn(ip), false);
    assert.equal(domainIps[4].isIn(ip), false);
  });
  it('IP一致', function() {
    var ip = '172.16.21.23'
    assert.equal(domainIps[0].isIn(ip), false);
    assert.equal(domainIps[1].isIn(ip), false);
    assert.equal(domainIps[2].isIn(ip), false);
    assert.equal(domainIps[3].isIn(ip), true);
    assert.equal(domainIps[4].isIn(ip), true);
  });
  it('顶级域名', function() {
    var ip = 'aaa.bbb.baidu.com'
    assert.equal(domainIps[0].isIn(ip), false);
    assert.equal(domainIps[1].isIn(ip), false);
    assert.equal(domainIps[2].isIn(ip), true);
    assert.equal(domainIps[3].isIn(ip), false);
    assert.equal(domainIps[4].isIn(ip), false);
  });
});